#ifndef SHADOW_CASTER_ENTITY_HPP
#define SHADOW_CASTER_ENTITY_HPP

////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <string>

#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/Graphics/Texture.hpp>
#include <SFML/Graphics/Sprite.hpp>

#include <SmegTools/Config.h>
#include <SmegCore/Entity/MovableEntity.hpp>

#include <SmegTools/Debug/DebugNew.hpp>

namespace smeg {
    namespace core {
        class EntityManager;
    }

    namespace light {
        class Hull;
        
////////////////////////////////////////////////////////////
/// Represents an entity that casts shadows
////////////////////////////////////////////////////////////
class ShadowCasterEntity : public core::MovableEntity {
public:
    ////////////////////////////////////////////////////////////
    /// Constructor
    ///
    /// \param _pRW :           Render window
    /// \param _Center :        Center of the entity
    /// \param _Velocity:       Velocity of the entity
    /// \param _fMass:          Mass of the entity
    /// \param _fMaxSpeed:      Maximum speed the entity can go
    /// \param _fAngleDeg :     Rotation angle
    /// \param _bIsStatic :     Static or dynamic ?
    ///
    ////////////////////////////////////////////////////////////
                                ShadowCasterEntity( sf::RenderWindow* _pRW,
                                    const sf::Vector2f& _Center         = sf::Vector2f(),
                                    const sf::Vector2f& _Velocity       = sf::Vector2f(),
                                    float _fMass                        = 1.0f,
                                    float _fMaxSpeed                    = DEFAULT_MAX_SPEED,
                                    float _fAngleDeg                    = 0.0f,
                                    bool _bIsStatic                     = false );
    ////////////////////////////////////////////////////////////
    /// Constructor with a sprite
    ///
    /// \param _pRW :           Render window
    /// \param _TextureName :   Name of the texture to associate with the sprite (in the DataManager)
    /// \param _Center :        Center of the entity
    /// \param _Velocity:       Velocity of the entity
    /// \param _fMass:          Mass of the entity
    /// \param _fMaxSpeed:      Maximum speed the entity can go
    /// \param _fAngleDeg :     Rotation angle
    /// \param _bIsStatic :     Static or dynamic ?
    ///
    ////////////////////////////////////////////////////////////
                                ShadowCasterEntity( sf::RenderWindow* _pRW,
                                    const std::string& _TextureName, 
                                    const sf::Vector2f& _Center         = sf::Vector2f(),
                                    const sf::Vector2f& _Velocity       = sf::Vector2f(),
                                    float _fMass                        = 1.0f,
                                    float _fMaxSpeed                    = DEFAULT_MAX_SPEED,
                                    float _fAngleDeg                    = 0.0f,
                                    bool _bIsStatic                     = false );
    ////////////////////////////////////////////////////////////
    /// Copy Constructor
    ///
    /// \param _Copy :          Entity to copy from
    ///
    ////////////////////////////////////////////////////////////
                                ShadowCasterEntity( const ShadowCasterEntity& _Copy );
    ////////////////////////////////////////////////////////////
    /// Destructor
    ///
    ////////////////////////////////////////////////////////////
    virtual                     ~ShadowCasterEntity();

    CREATE_CLONE_FUNC( ShadowCasterEntity, core::BaseEntity )

    /*********************** Accessors ************************/
    bool                        SetSprite( const std::string& _SpriteFilename );
    
    void                        SetHull( light::Hull* _hull );
    void                        RemoveHull();
    void                        NullifyHull();
    light::Hull*                GetHull() const;

    virtual void                SetCenter( float _fX, float _fY );
    virtual void                Move( float _fX, float _fY );
    
    virtual void                SetAngleRad( float _fAngleRad );
    virtual void                RotateRad( float _fAngleRad );

protected:
    friend class                EntityManager;
    
    ////////////////////////////////////////////////////////////
    /// Default Constructor
    ////////////////////////////////////////////////////////////
                                ShadowCasterEntity();
        
    ////////////////////////////////////////////////////////////
    /// Change the staticity of the entity
    ///
    /// \param _bIsStatic :     Static or dynamic ?
    ///
    ////////////////////////////////////////////////////////////
    virtual void                SetStatic( bool _bIsStatic );
        
    /******************* Protected members ********************/
    light::Hull*                m_pHull; /// Hull of the entity

#ifdef _DEBUG
public:
    virtual void                DebugRender( const sf::Color& _Color = sf::Color::White ) const;
#endif // _DEBUG
};

/************************** Inline ************************/
inline void ShadowCasterEntity::NullifyHull() {
    m_pHull = NULL;
}

inline light::Hull* ShadowCasterEntity::GetHull() const {
    return m_pHull;
}

    } // namespace light
} // namespace smeg

#include <SmegTools/Debug/DebugNewOff.hpp>

#endif // SHADOW_CASTER_ENTITY_HPP
